<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
    <style>
        body {
            margin: 0 auto;
            text-align: center;
        }

        h2 {
            text-align: center;
        }

        table {
            margin: 0 auto;
            text-align: center;
        }
    </style>
</head>
<body>
<h2>美国职业篮球联盟(NBA)球员信息</h2>
<form method="get" action="list">
    球员姓名：<input type="text" name="pname" value="${param.pname}"/>
    所属球队：<select name="cid">
    <option value="请选择" disabled selected>--请选择--</option>
    <c:forEach var="clubs" items="${clubsList}">
        <option value="${clubs.cid}">${clubs.cname}</option>
    </c:forEach>

</select>
    <input type="submit" value="查询"/>
</form>
<a href="${pageContext.request.contextPath}/players/toAdd">添加新球员信息</a>

<table border="1" cellspacing="1">
    <tr>
        <th>球员编号：</th>
        <th>球员名称：</th>
        <th>出生日期（yyyy-MM-dd）：</th>
        <th>球员身高（单位：cm）：</th>
        <th>球员体重（单位：kg）：</th>
        <th>球员位置：</th>
        <th>所属球队：</th>
        <th>相关操作：</th>

    </tr>

    <c:forEach items="${list}" var="players">
        <tr>
            <td>${players.pid}</td>
            <td>${players.pname}</td>
            <td>${players.birthday}</td>
            <td>${players.height}</td>
            <td>${players.weight}</td>
            <td>${players.position}</td>

            <td>
                <c:if test="${players.cid==1}">
                    <c:out value="马刺">
                    </c:out>
                </c:if>
                <c:if test="${players.cid==2}">
                    <c:out value="太阳">
                    </c:out>
                </c:if>
                <c:if test="${players.cid==3}">
                    <c:out value="勇士">
                    </c:out>
                </c:if>
                <c:if test="${players.cid==4}">
                    <c:out value="湖人">
                    </c:out>
                </c:if>
            </td>
            <td>
                <a href="javascript:void(0)" onclick="isDel(${players.pid})">删除</a>
            </td>
        </tr>
    </c:forEach>

</table>


<script>
    function viewUser(id) {
        location.href = 'view?id=' + id
    }

    function modifyUser(id) {
        location.href = 'toEdit?id=' + id
    }

    function isDel(id) {
        if (confirm("确定要删除？")) {
            location.href = "del?id=" + id
        }
    }

    $(function (){
        $("tr:odd").css("backgroundColor","pink")
    })

</script>
</body>
</html>
